package modelkontrol;

import model.MPasien;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

import hibernate.HibernatePasienUtil;

public class KontrolPasien {
	public void savePasien(String nama)
	{
		Session session = HibernatePasienUtil.getSessionFactory().openSession();
		Transaction transaction = null;
	
		try {
			transaction = session.beginTransaction();
			MPasien pasien = new MPasien();
			pasien.setId("1");
			pasien.setNama(nama);
			session.save(pasien);
			transaction.commit();
		} catch (HibernateException e) {
			transaction.rollback();
			e.printStackTrace();
		} finally {
			session.close();
		}
	}

}
